// 第四版
Function.prototype.bind2 = function (context) {

    var self = this;
    var args = Array.prototype.slice.call(arguments, 1);

    var fNOP = function () {};

    var fBound = function () {
        var bindArgs = Array.prototype.slice.call(arguments);
        return self.apply(this instanceof fNOP ? this : context || this, args.concat(bindArgs));
    }

    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();
    // fBound.prototype = this.prototype;
    return fBound;
}

var value = 2;
var foo = {
    value: 1
};

function bar() {
    // console.log(this.value);
}
bar.prototype = {
    test:1
}

let fn = bar.bind2(foo);
fn.prototype = {
    test:2
}
// fn.prototype.test = 2;
let obj1 = new fn();
console.log(obj1.test)//2

let obj2 = new bar();
console.log(obj2.test)//1
